<!--
 * @Date: 2024-10-11 14:27:37
 * @LastEditors: Lcx l1556461835@163.com
 * @LastEditTime: 2024-10-30 12:31:24
 * @FilePath: \frontEnd\pages\pendOrder\index.vue
 * @Description:
-->
<template>
  <div>
    <page-title title="已发起评审/订单详情" home-path="/sale/home"></page-title>
    <div class="pageMain">
      <div class="pageMain-title">
        <span>待处理订单详情</span>
      </div>
      <div class="pageMain-body">
        <div class="orderTip"></div>
        <order-detail :form-data="orderInfo" style="margin: auto" _width="600px">
          <template slot="orderFoot">
            <span class="flex-container">
              <el-button type="success" size="small" @click="handleEdit">修改信息</el-button>
              <el-button v-if="isShow" type="warning" size="small" @click="handleRouterGo">核定外委</el-button>
            </span>
          </template>
        </order-detail>
      </div>
    </div>
    <el-dialog :visible.sync="dialogVisible" :close-on-click-modal="false" title="修改信息"  width="100%" >
      <reviews ref="reviews" @close="getData"/>
    </el-dialog>
  </div>
</template>

<script>
import OrderDetail from "../../components/OrderDetail.vue";
import PageTitle from "../../components/PageTitle.vue";
import reviews from "../sale/reviews";
import { SALE_PENDING_ORDER_INFO } from "@/lib/Api.js";
import { post, get } from "@/lib/Util.js";
export default {
  components: {
    OrderDetail,
    PageTitle,
    reviews
  },
  data() {
    return {
      isShow: true,
      orderInfo: {},
      dialogVisible: false
    };
  },
  mounted() {
    if (this.$route.params.id) {
      this.getData(this.$route.params.id);
      this.isShow = this.$route.params.isShow;
    }
  },
  methods: {
    handleRouterGo() {
      this.$router.push({
        name: "checkYe",
        params: {
          id: this.orderInfo.id
        }
      });
    },
    handleEdit() {
      this.dialogVisible = true;
      this.$nextTick(() => {
        this.$refs.reviews.SetData(this.orderInfo);
      });
    },
    getData(params) {
      this.dialogVisible = false;
      post(SALE_PENDING_ORDER_INFO, {
        contractInfoId: params
      }).then(res => {
        console.log(res);
        this.orderInfo = res.data;
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.orderTip {
  height: 30px;
  margin: 6px 0;
}
.flex-container {
  display: flex;
  justify-content: flex-end;
}
</style>
